/**
 * create by young (young2f@outlook.com) on 2020/12/4
 * 实验库存
 */
'use strict';
const model = require('../base/tModelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    code: { type: String, _type: 'code', title: '编码', required: true, enableArea: [  ] },
    name: { type: String, _type: 'string', title: '原料名称/厂家', required: true, enableArea: [ 'table', 'detail', 'search' ] },
    count: { type: Number, _type: 'number', title: '数量', required: true, enableArea: [ 'table', 'detail', 'search' ] },
    unit: { type: String, _type: 'string', title: '单位', required: true, enableArea: [ 'table', 'detail', 'search' ] },
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  _schema.index({'code':1});
  return connect.model('ExperimentStore', _schema);
};
